/**
 * 
 */
package com.feeyin.radar.crm.model;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

import com.feeyin.radar.commons.DateUtils;

/**
 * @author E547415
 *
 */
public class ContractCase 
{
	private Integer id;
	private String contractId;
	private String applicationCode;
	private String caseCode;
	private String description;
	private Double costValue = 0.0;
	private Double discount;
	private Double operationCost;
	private Double officialCost;
	private Double proxyCost;	
	private Date applicationDate;
	private String type;	
	private Integer processId;	
	private Date modifyDate;
	private Integer processGroupId;
	private Integer officialCostId;
	private Integer officialCostStatus;
	private Integer operationCostId;
	private Integer operationCostStatus;
	
	public Integer getOfficialCostId() {
		return officialCostId;
	}
	public void setOfficialCostId(Integer officialCostId) {
		this.officialCostId = officialCostId;
	}
	public Integer getOfficialCostStatus() {
		return officialCostStatus;
	}
	public void setOfficialCostStatus(Integer officialCostStatus) {
		this.officialCostStatus = officialCostStatus;
	}
	public Integer getOperationCostId() {
		return operationCostId;
	}
	public void setOperationCostId(Integer operationCostId) {
		this.operationCostId = operationCostId;
	}
	public Integer getOperationCostStatus() {
		return operationCostStatus;
	}
	public void setOperationCostStatus(Integer operationCostStatus) {
		this.operationCostStatus = operationCostStatus;
	}

	private Long attachId;
	List<CaseAttach> attaches;


	private List<SubContractCase> subCaseList;
	private String prefixCaseName;
	private String suffixCaseName;
	private String mark;
	
	private Integer pageStartRow;
	private Integer pageEndRow;
	private Contract contract;
	private ContractCaseType contractCaseType;
	private Process process;
	public ContractCase(){
		
	}
	public ContractCase(Map resultMap){
		this.id=Integer.valueOf(resultMap.get("id").toString());
		this.contractId=resultMap.get("contractId").toString();
		this.applicationCode=resultMap.get("applicationCode").toString();
		this.caseCode=resultMap.get("caseCode").toString();
		this.description=resultMap.get("description").toString();
		this.costValue=Double.valueOf(resultMap.get("costValue").toString());
		this.discount=Double.valueOf(resultMap.get("discount").toString());
		this.operationCost=Double.valueOf(resultMap.get("operationCost").toString());
		this.officialCost=Double.valueOf(resultMap.get("officialCost").toString());
		this.proxyCost=Double.valueOf(resultMap.get("proxyCost").toString());
		this.applicationDate=DateUtils.stringDateConvertDate(resultMap.get("applicationDate").toString(), "yyyy-MM-dd");
		this.type=resultMap.get("type").toString();
		this.processId=Integer.valueOf(resultMap.get("processId").toString());
		this.processGroupId=Integer.valueOf(resultMap.get("processGroupId").toString());
		this.modifyDate=DateUtils.stringDateConvertDate(resultMap.get("modifyDate").toString(), "yyyy-MM-dd");
		this.prefixCaseName=resultMap.get("prefixCaseName")==null?"":resultMap.get("prefixCaseName").toString();
		this.suffixCaseName=resultMap.get("suffixCaseName")==null?"":resultMap.get("suffixCaseName").toString();
	}

	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public String getContractId() {
		return contractId;
	}
	public void setContractId(String contractId) {
		this.contractId = contractId;
	}
	public String getApplicationCode() {
		return applicationCode;
	}
	public void setApplicationCode(String applicationCode) {
		this.applicationCode = applicationCode;
	}
	public String getCaseCode() {
		return caseCode;
	}
	public void setCaseCode(String caseCode) {
		this.caseCode = caseCode;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public Double getCostValue() {
		return (costValue == null) ? 0.0 : costValue;
	}
	public void setCostValue(Double costValue) {
		this.costValue = costValue;
	}
	public Double getDiscount() {
		return (discount == null) ? 0.0 : discount;
	}
	public void setDiscount(Double discount) {
		this.discount = discount;
	}
	public Double getOperationCost() {
		return (operationCost == null) ? 0.0 : operationCost;
	}
	public void setOperationCost(Double operationCost) {
		this.operationCost = operationCost;
	}
	public Double getOfficialCost() {
		return (officialCost == null) ? 0.0 : officialCost;
	}
	public void setOfficialCost(Double officialCost) {
		this.officialCost = officialCost;
	}
	public Double getProxyCost() {
		return (proxyCost == null) ? 0.0 : proxyCost;
	}
	public void setProxyCost(Double proxyCost) {
		this.proxyCost = proxyCost;
	}
	public ContractCaseType getContractCaseType() {
		return contractCaseType;
	}
	public void setContractCaseType(ContractCaseType contractCaseType) {
		this.contractCaseType = contractCaseType;
	}
	public String getApplicationDate() {
		SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
		if(applicationDate==null)
			applicationDate = new Date();
		return sdf.format(applicationDate).toString();
	}
	public void setApplicationDate(Date applicationDate) {
		this.applicationDate = applicationDate;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}		
	public Integer getProcessId() {
		return processId;
	}
	public void setProcessId(Integer processId) {
		this.processId = processId;
	}
	public Process getProcess() {
		return process;
	}
	public void setProcess(Process process) {
		this.process = process;
	}
	public String getCaseTypeName(){
		if(contractCaseType != null)
			return contractCaseType.getType()+"-"+contractCaseType.getScope();
		else
			return "";
	}
	public Date getModifyDate() {
		return modifyDate;
	}
	public void setModifyDate(Date modifyDate) {
		this.modifyDate = modifyDate;
	}
	
	public String getProcessName(){
		if(process != null)
			return process.getName();
		else
			return "";
	}
	public Integer getProcessGroupId() {
		return processGroupId;
	}
	public void setProcessGroupId(Integer processGroupId) {
		this.processGroupId = processGroupId;
	}	
	
	public Integer getProcessIndex()
	{
		return process.getIndexFlag();
	}

	public String getContractCaseFullName()
	{
		return caseCode;
	}
	public List<SubContractCase> getSubCaseList() {
		if(subCaseList==null)
			subCaseList = new ArrayList<SubContractCase>();
		return subCaseList;
	}
	public void setSubCaseList(List<SubContractCase> subCaseList) {
		this.subCaseList = subCaseList;
	}
	public String getPrefixCaseName() {
		return prefixCaseName;
	}
	public void setPrefixCaseName(String prefixCaseName) {
		this.prefixCaseName = prefixCaseName;
	}
	public String getSuffixCaseName() {
		return suffixCaseName;
	}
	public void setSuffixCaseName(String suffixCaseName) {
		this.suffixCaseName = suffixCaseName;
	}
	public String getMark() {
		if(mark==null||"".equals(mark)){
			if(caseCode!=null&&!"".equals(caseCode)&&contractCaseType!=null&&!"".endsWith(contractCaseType.getId())){
				return caseCode+"_"+contractCaseType.getId();
			}
		}
		return mark;
	}
	public void setMark(String mark) {
		this.mark = mark;
	}
	public Long getAttachId() {
		return attachId;
	}
	public void setAttachId(Long attachId) {
		this.attachId = attachId;
	}
	public List<CaseAttach> getAttaches() {
		if(attaches==null)
			attaches = new ArrayList<CaseAttach>();
		return attaches;
	}
	public void setAttaches(List<CaseAttach> attaches) {
		this.attaches = attaches;
	}
	
	public Contract getContract() {
		return contract;
	}
	public void setContract(Contract contract) {
		this.contract = contract;
	}
	public Integer getPageStartRow() {
		return pageStartRow;
	}
	public void setPageStartRow(Integer pageStartRow) {
		this.pageStartRow = pageStartRow;
	}
	public Integer getPageEndRow() {
		return pageEndRow;
	}
	public void setPageEndRow(Integer pageEndRow) {
		this.pageEndRow = pageEndRow;
	}
}
